home *** CD-ROM | disk | FTP | other *** search
- REMAPPING THE KEYBOARD
-
- A character that you type at the keyboard can take on 256 dif-
- ferent values, from 0 to 255. On the IBM PC, the ASCII characters are
- numbered from 0 to 127, and the IBM extended characters are numbered
- from 128 to 255. All of the function key combinations and numeric
- keypad combinations fall into the extended character set.
-
- The editor has an internal table which is used to translate one
- value into another. This internal table is 256 bytes long, with byte 0
- holding the translation value for keystroke value 0, byte 1 holding
- the value for keystroke 1, etc. The default values for this table in-
- dicate no translations (ie keystroke number n is translated into value
- n.)
-
-
- AN EXAMPLE OF REMAPPING
-
- As an example where translation may be desirable, let's consider a
- very simple remapping of the keyboard. The command that is associated
- with the F1 function key is <DELETE LINE>. Let's say that you would
- like the <HELP> function to be assigned to the F1 key, and the <DELETE
- LINE> function assigned to the <ALT> D key. Currently, the <HELP>
- function is assigned to the <ALT> H key.
-
- To find out what keystroke values the F1, <ALT> D and <ALT> H
- keys produce, use the <TEST KEYS> command from the editor.
- This command is done by pressing the ALT F10 key. The <TEST KEYS> com-
- mand prompts you for a keystroke, and then prints the value that the
- keystroke produced.
-
- After invoking the <TEST KEYS> command, we find that the following
- values are produced :
-
- F1 187
- ALT D 60
- ALT H 163
-
- What we would like to do is have the F1 key "generate" the <ALT> H
- keystroke, and have the <ALT> D key "generate" the F1 value. In other
- words, we would like to fool the editor into thinking that when the F1
- key is pressed, the <ALT> H key was really pressed.
-
- To effect these changes, we would like to put the value 163 into
- byte 187 of the table, and put value 187 into byte 160 of the table.
- How can we do this without going altering the editor's executable
- file?
-
-
- THE KEYTABLE FILE
-
- The file which holds the keystroke translation values is called
- "KEYTABLE.NYW". When the editor starts up, it will first look in your
- current subdirectory for the KEYTABLE.NYW file. If the editor doesn't
- find it there, then the editor will search the directories listed in
- your DOS search path. If this file still isn't found, then the in-
- ternal table is filled sequentially with the values 0 through 255.
- This means that no remapping will be performed.
-
- The KEYTABLE.NYW file contains one or more tables which are 256
- bytes long, with byte i corresponding to keystroke i. The editor comes
- with a default KEYTABLE.NYW file. It also comes with several utilities
- to create and alter the KEYTABLE.NYW file.
-
- The first utility we will talk about is called KEYCOMP.EXE. This
- program reads a keystroke configuration file and generates a
- KEYTABLE.NYW file from it. A keystroke configuration file contains a
- list of keystrokes and their corresponding values.
-
- Each line of the keystroke configuration file has the form :
-
- key=func
-
- The "key" can be a decimal number, a single character between
- single quotes, ^char (a control character between 0 and 31), F# where
- '#' is a number between 1 and 10 (this is a normal function key), AF#
- (ALT function key), SF# (SHIFT function key), CF# (CTRL function key),
- or @char (ALT character key).
-
- "Func" is a number representing the value that the key produces.
-
- Here are some examples :
-
- 120=122 (the key with the value 120 produces 122)
- '#'=289 (a pound sign produces 289)
- ^C=14 (CTRL C produces 14)
- F1=160 (F1 produces 160)
- @A=198 (ALT A produces 198)
- SF9=130 (SHIFT f9 produces 130)
-
- Any keystrokes which aren't mentioned in the configuration file
- will just be translated into themselves.
-
- To run the keystroke compiler, type the command
-
- KEYCOMP filename
-
- where filename is the name of the keystroke configuration file. If
- everything goes well, the KEYTABLE.NYW file will be created. You can
- not TYPE out the KEYTABLE.NYW file since it contains binary data.
- However, you can examine it with various disk utilities (such as the
- NORTON Utilities).
-
- The second utility is called KEYCONF.EXE. This program generates a
- default keystroke configuration file. There are 256 lines in the
- generated file. The file looks like this :
-
- 0=0
- 1=1
- ...
- 255=255
-
- The output from this program is written to the screen. You can
- redirect the output to a file be giving the command :
-
- KEYCONF > keyfile (or any other name)
-
- Once this sample keystroke configuration file is generated, you
- can alter it with any text editor, and then compile it using
- KEYCOMP.EXE.
-
- The third utility is called KEYTEST.EXE. This program waits for
- you to type a keystroke, and then prints out the value of that
- keystroke. Hitting the <ESC> key will stop the program. This program
- is also simulated by the <TEST KEYS> command of the editor.
-
-
- PREFIXES
-
- Some people would like to have the editor emulate their favorite
- word processor, and hence, will make key maps which map the function
- keys of the editor into the keystrokes that their word processor
- requires. Some word processors use a two-keystroke sequence to
- generate a command. One of the most well-known examples of this is
- WordStar (WordStar is a trademark of MicroPro Inc.). For instance, the
- keystroke sequence CTRL K D is used to exit WordStar.
-
- You can specify prefixes in the keystroke redefinition file which
- is compiled by the KEYCOMP.EXE program. A prefix line is of the form :
-
- PREFIX <keystroke>
-
- The PREFIX statement creates a 256 byte table which contains the
- commands generated by the second key of the sequence. As an example,
- you press CTRL D right now to exit the editor. CTRL D generates a
- keystroke value of 4. If you would like to use the CTRL K D keystroke
- combination to exit the editor instead, then your keystroke file
- should contain a line like this :
-
- PREFIX ^K
- ..... list of CTRL K commands
- D=4
- ......
-
-
- A prefix command table ends when the compiler encounters another
- PREFIX statement, or when the compiler reaches the end of the
- redefinition file.
-
- All of the prefix definitions should come after the definitions
- for the main table. For a good example, examine the WSKEYS file which
- comes with the keyboard remapping facility. This file contains the
- keystroke definitions to configure the keyboard like WordStar.
-
-
- SOURCE FILES
-
- Included in the editor package are the source files to the above
- mentioned utilities. We request that if you improve these utilities,
- that you send the source back to us so that we can incorporate it in
- future releases. In exchange, you will receive a free copy of the next
- release of the editor.
-